from selenium.webdriver import Chrome,Firefox
from selenium.webdriver.chrome.options import Options

def get_chrombrowser():
    options = Options()
    options.add_argument('--ignore-certificate-errors') # 忽略证书错误
    options.add_argument('--user-data-dir=D:\caiyi\patent_spider\chromefile') #指定用户文件夹
    options.add_argument("--ssl-version-max")
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('useAutomationExtension', False)
    desired_capabilities = {
        "acceptInsecureCerts": True
    }
    executable_path = r'C:\Program Files\Google\Chrome\Application\chromedriver'
    chrome_browser = Chrome(
        executable_path=executable_path, options=options,desired_capabilities=desired_capabilities)
    chrome_browser.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {"source": """Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"""})
    return (chrome_browser)
